package messages;

import java.io.IOException;
import java.sql.SQLException;
import ocsf.server.ConnectionToClient;
import controllers.DBConnection;

 // this class implements the logout from the system
 
public class LogoutMessage {
	
	private static  ConnectionToClient client ;
	

public LogoutMessage(String[] str, ConnectionToClient client) {
	super();
	this.client = client;
	}

// setting connected to 0 in DB and logging out from the system 

public void activate(String ID) throws SQLException, IOException {
	DBConnection sc = new DBConnection();
	java.sql.PreparedStatement ps = sc.getDBConnection().prepareStatement("Update sgi_system.users SET Connected=? WHERE ID=?");
	ps.setInt(1, 0);
	ps.setString(2, ID);
	ps.executeUpdate();
	//client.sendToClient("LogoutCompleted");
	ps.close();
	}
  
	 
	 
}
